package com.jeesite.modules.exam.quota.service;

import java.util.List;

import com.jeesite.common.lang.StringUtils;
import com.jeesite.modules.exam.quota.entity.DcSupExamQuotaInfo;
import com.jeesite.modules.exam.quota.entity.DcSupExamSumQuota;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeesite.common.entity.Page;
import com.jeesite.common.service.CrudService;
import com.jeesite.modules.exam.quota.entity.DcSupExamQuotaOrg;
import com.jeesite.modules.exam.quota.dao.DcSupExamQuotaOrgDao;
import com.jeesite.modules.file.utils.FileUploadUtils;

/**
 * 考核任务指标表-被考核单位Service
 * @author xhc
 * @version 2022-05-28
 */
@Service
@Transactional(readOnly=false)
public class DcSupExamQuotaOrgService extends CrudService<DcSupExamQuotaOrgDao, DcSupExamQuotaOrg> {
	
	/**
	 * 获取单条数据
	 * @param dcSupExamQuotaOrg
	 * @return
	 */
	@Override
	public DcSupExamQuotaOrg get(DcSupExamQuotaOrg dcSupExamQuotaOrg) {
		return super.get(dcSupExamQuotaOrg);
	}
	
	/**
	 * 查询分页数据
	 * @param dcSupExamQuotaOrg 查询条件
	 * @param dcSupExamQuotaOrg.page 分页对象
	 * @return
	 */
	@Override
	public Page<DcSupExamQuotaOrg> findPage(DcSupExamQuotaOrg dcSupExamQuotaOrg) {
		return super.findPage(dcSupExamQuotaOrg);
	}
	
	/**
	 * 查询列表数据
	 * @param dcSupExamQuotaOrg
	 * @return
	 */
	@Override
	public List<DcSupExamQuotaOrg> findList(DcSupExamQuotaOrg dcSupExamQuotaOrg) {
		return super.findList(dcSupExamQuotaOrg);
	}
	
	/**
	 * 保存数据（插入或更新）
	 * @param dcSupExamQuotaOrg
	 */
	@Override
	@Transactional(readOnly=false)
	public void save(DcSupExamQuotaOrg dcSupExamQuotaOrg) {
		super.save(dcSupExamQuotaOrg);
		// 保存上传图片
		FileUploadUtils.saveFileUpload(dcSupExamQuotaOrg, dcSupExamQuotaOrg.getId(), "dcSupExamQuotaOrg_image");
		// 保存上传附件
		FileUploadUtils.saveFileUpload(dcSupExamQuotaOrg, dcSupExamQuotaOrg.getId(), "dcSupExamQuotaOrg_file");
	}
	
	/**
	 * 更新状态
	 * @param dcSupExamQuotaOrg
	 */
	@Override
	@Transactional(readOnly=false)
	public void updateStatus(DcSupExamQuotaOrg dcSupExamQuotaOrg) {
		super.updateStatus(dcSupExamQuotaOrg);
	}
	
	/**
	 * 删除数据
	 * @param dcSupExamQuotaOrg
	 */
	@Override
	@Transactional(readOnly=false)
	public void delete(DcSupExamQuotaOrg dcSupExamQuotaOrg) {
		super.delete(dcSupExamQuotaOrg);
	}

    public List<DcSupExamQuotaOrg> findOrgByExamId(String examId) {
		return dao.findOrgByExamId(examId);
    }

    public Integer findGoalOrg(DcSupExamQuotaInfo dan) {
		return dao.findGoalOrg(dan);
    }

	public void deleteOrg(DcSupExamQuotaOrg orgDelete) {
		dao.deleteOrg(orgDelete);
	}

	public List<DcSupExamQuotaOrg> findOrgByExamIdAndVersion(DcSupExamSumQuota dcSupExamSumQuota) {
		if (dcSupExamSumQuota.getVersionNumber() == null){
			return findOrgByExamId(dcSupExamSumQuota.getExamId());
		}
		return dao.findOrgByExamIdAndVersion(dcSupExamSumQuota.getExamId(),dcSupExamSumQuota.getVersionNumber());
	}
}